/**
 * Created by Panda on 14/11/2016
 */
(function () {
    'use strict';

    angular
        .module('com.akxx.aqzyk')
        .service('Back', Back);


    /** @ngInject */
    function Back($state, Storage) {
        var self = this;

        self.setBack = function (state, param, replace, force) {
            var nowBack = Storage.get("back");
            if (!nowBack || force) {
                Storage.set("back", {
                    state: state,
                    param: param,
                    replace: !replace
                });
            }
        };

        /**
         * 以后如果有需要再实现逻辑，现在暂时空着
         * */
        self.setBackUrl = function (url, replace) {

        };

        self.back = function () {
            var back = Storage.get("back");
            $state.go(back.state, back.param || {}, {location: back.replace ? "replace" : "", reload: true});
        }

    }

})();
